<%@page import="dao.QuestionsDao"%>
<%@page import="pojo.Questions"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
.head {
	text-align: center;
}

td, th {
	white-space: nowrap;
}

th {
	background-color: #afb4db;
}

table tr:nth-child(odd) {
	background: #ccc;
}
</style>

</head>

<body>
	<h1 class="head">在线问答</h1>
	<p class="head">
		<a href="question.jsp">我要提问</a>
	</p>

	<table class="head" id="content" style="margin:auto">
		<tr>
			<th>序号</th>
			<th>问题</th>
			<th>回答次数</th>
			<th>最后修改</th>
		</tr>
		<%
			List<Questions> quest = QuestionsDao.QueDao.findAllQuestions();
			for (int i = 0, j = 1; quest != null && i < quest.size(); i++, j++) {
				Questions questions = quest.get(i);
		%>
		<tr>
			<td><%=j%></td>
			<td><a href="#"
				style="color:<%=questions.getAnswerCount() != 0 ? "black" : "red"%>"><%=questions.getTitle()%></a></td>
			<td><%=questions.getAnswerCount()%></td>
			<td><%=questions.getLastModified()%></td>
		</tr>
		<%
			}
		%>
	</table>




</body>
</html>
